#ifndef RESPONSE__H
#define RESPONSE__H
#include <map>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>
#include "Request.h"

class Response;

class ResponseHead{
private:
    friend class Response;
    std::string version;  // 协议版本
    int status;  // 状态码
    std::string describe; // 描述
    std::map<std::string,std::string> msg;  // 头部字段信息
    std::string text;  // 正文
public:
    void setStatus(int status);
    void setText(std::string text);
    void setDescribe(std::string describe);
    void setVersion_self(const std::string& version);  // 引用版本
    void setVersion(std::string version);  // 拷贝版本
    // void setVersion(std::string version);
    void setMsg(std::string key,std::string value);
    const std::map<std::string,std::string>& getMsg() const {
        return msg;
    }
    void clear();
};

class Response{
private:
    ResponseHead pesHead;
    int size;
public:
    Response(){
        // pesHead.setVersion(head.getVersion());
        // pesHead.setMsg("Content-Type","text/html");
    }
    Response(std::shared_ptr<RequestHead> head){
        pesHead.setVersion_self(head->getVersion());
        pesHead.setMsg("Content-Type","text/html");
    }
    std::string returnResponse();
    void setStatus(int status);
    void setText(std::string text);
    void setDescribe(std::string describe);
    void setVersion(std::string version);
    void setVersion_self(const std::string& version);
    void setMsg(std::string key,std::string value);
    void clear();
    int get_size(){
        return size;
    }
    ~Response(){
        // printf("Response delete...\n");
    }
};

#endif 